<template>
	<view style="padding: 30rpx;">
		<view>异步接口</view>
		<button @click="setStorage()">setStorage设置</button>
		<button @click="" type="primary">getStorage获取</button>
		<button @click="" type="primary">getStorageInfo获取列表</button>
		<button @click="" type="warn" plain="true">RemoveStorage删除</button>
		<button @click="" type="warn">clearStorage清空</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				name: 'zhangsan',
				timer1: null
			}
		},
		methods: {
			callStorageFun(parm) {
				console.log("callStorageFun==>parm" + parm);
				switch (parm) {
					case 1:
						//存某一个字段到本地 字段名：值
						uni.setStorage({
							key: 'UserName',
							data: 'cjs',
							success() {
								console.log('UserName 存储成功');
							}
						})
						break;
					case 2:
						uni.getStorage({
							key: 'Account',
							success() {
								console.log("读取UserName成功 result.data:"+ result.data);
							},
							fail() {
								console.error("读取UserName失败");
							}
						});
						break;
						case 3:
						uni.gatstorageInfo({
							success:function(result){
								console.log("获取所有缓存字段:" + result.keys);
								
							}
							
						})
						
				}
			}
		}
	}
</script>

<style>
	button {
		margin: 20rpx;
	}
</style>